package tp.badugi.client.guiViews;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridLayout;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.border.EmptyBorder;

import tp.badugi.client.GuiClient;

public class GetActionAmoutView extends JFrame{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 4713931331622947803L;

	private GuiClient client; 
	
	public final String actionAmountTextFiledDefaultText = "How much?";

	private final Dimension actionAmountViewSize = new Dimension(150, 70);
	
	private final Dimension gameViewSize = new Dimension(800, 600);

	public JButton actionAmountButton = new JButton("Confirm");
	
	private JPanel actionAmountPanel = new JPanel();
	
	public JTextField actionAmountTextFiled = 
			new JTextField(this.actionAmountTextFiledDefaultText);
	
	public GetActionAmoutView(GuiClient client) {
		
		this.client = client;
		
		this.makeView();
		this.refreshView();
	}
	
	private void makeView(){
		this.setTitle(this.client.title);
		
		this.setBounds(
				(int)(this.client.windowBoundPoint.getX() + (this.gameViewSize.getWidth()-this.actionAmountViewSize.getWidth())/2),
				(int)(this.client.windowBoundPoint.getY() + (this.gameViewSize.getHeight()-this.actionAmountViewSize.getHeight())/2),
				(int)this.actionAmountViewSize.getWidth(), (int)this.actionAmountViewSize.getHeight());
		
		this.actionAmountPanel.setBackground(Color.BLUE);
		
		this.actionAmountPanel.setLayout(new GridLayout(2,1));
		this.actionAmountPanel.setBorder(new EmptyBorder(10, 10, 10, 10) );
		this.add(this.actionAmountPanel);

		this.actionAmountPanel.add(this.actionAmountTextFiled);
		this.actionAmountPanel.add(this.actionAmountButton);
		this.actionAmountButton.addActionListener(this.client);
		
		this.setUndecorated(true);
		this.setVisible(true);
		this.setResizable(false);
		this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
	}
	
	public void refreshView(){
		this.actionAmountTextFiled.setText(this.actionAmountTextFiledDefaultText);
	}
}
